package com.neusoft.elmboot.service.impl;

import java.util.List;

import com.neusoft.elmboot.dto.FoodDTO;
import com.neusoft.elmboot.po.Business;
import com.neusoft.elmboot.service.ex.DataNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neusoft.elmboot.mapper.FoodMapper;
import com.neusoft.elmboot.po.Food;
import com.neusoft.elmboot.service.FoodService;
import org.springframework.web.bind.annotation.GetMapping;

@Service
public class FoodServiceImpl implements FoodService{
	
	@Autowired
	private FoodMapper foodMapper;

	@Override
	public List<Food> listFoodByBusinessId(Integer businessId) {
		List<Food> list = foodMapper.listFoodByBusinessId(businessId);
		if(list != null && !list.isEmpty()){
			return list;
		}
		else{
			throw new DataNotFoundException("该商家不存在，获取食物列表失败!");
		}

	}

	@Override
	public List<Food> searchFood(FoodDTO foodDTO){
		List<Food> list = foodMapper.searchFood(foodDTO);
		if(list != null && !list.isEmpty()){
			return list;
		}
		else{
			throw new DataNotFoundException("没有找到相关商品信息!");
		}



	}
}
